aboutsummaryrefslogtreecommitdiff
path: root/src/pages/board/[board]/[tid].astro
blob: 80e7fbec805d79893a4252f04f7cd462dcfe2cee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
---
import Default from '../../../layouts/Default.astro';
import Thread from '../../../components/Thread.svelte'
import Comment from '../../../components/Comment.svelte'
import type Thread from '../../../models/Thread';

import { api } from '../../../lib/api';
import { processThreadIn } from '../../../lib/thread';

const { board } = Astro.params;
const data = await api('get', `thread/${board}/${Astro.params.tid}`);

if(data.status === 404) return Astro.redirect('/404');

const thread: Thread = await data.json();
await processThreadIn(board, thread, true);
const comments: Comment[] = thread.comments;
---

<Default>
  <Thread thread={thread} board={board}>
    {comments.map((comment) => (
      <Comment comment={comment} />
    ))}
  </Thread>
</Default>